General usage
[1] For scRNA-seq data, we suggest to revise the gene symbols with
rev_gene(). geneinfo is the system data.frame
containing the information of human and mouse from NCBI gene(updated in
June. 19, 2022). To use your own geneinfo data.frame,
please refer to demo_geneinfo() to build a new one, e.g.,
rat, zebrafish, Drosophila, C. elegans, etc.
library(scCrossTalk)
load(paste0(system.file(package = "scCrossTalk"), "/extdata/example.rda"))
# demo_geneinfo
demo_geneinfo()
#> symbol synonyms species
#> 1 A1BG A1B Human
#> 2 A1BG ABG Human
#> 3 A2MP1 A2MP Human
#> 4 Aco1 Aco Mouse
# demo_sc_data
demo_sc_data()
#> 6 x 6 sparse Matrix of class "dgCMatrix"
#> cell1 cell2 cell3 cell4 cell5 cell6
#> A1BG . 17 . . . .
#> A2M . . . 36 . 33
#> A2MP . . . 6 45 .
#> NAT1 1 21 . 32 11 11
#> NAT2 . . . 44 . 22
#> NATP 20 29 . . 10 6
# revise gene symbols
sc_data <- rev_gene(data = sc_data,data_type = "count",species = "Human",geneinfo = geneinfo)[2] create scCrossTalk object with create_scCrossTalk().
Users need to provide the raw count data and the cell type. scCrossTalk
will use NormalizeData() in Seurat to
normalize data by default. If your data has been normalized by other
methods, you can set the parameter if_normalize = FALSE
obj <- create_scCrossTalk(sc_data = sc_data, sc_celltype = sc_celltype, species = "Human", if_normalize = TRUE)
#> Warning: Feature names cannot have underscores ('_'), replacing with dashes
#> ('-')
# If your data has been normalized by other methods, you can set the parameter `if_normalize = FALSE`
# obj <- create_scCrossTalk(sc_data = sc_data, sc_celltype = sc_celltype,species = "Human", if_normalize = FALSE)[3] find highly expressed LR pairs with find_lrpairs().
Users need to provided the speices and lr pairs database.
lrpairs is the system data.frame containing the known LR
pairs of human and mouse from CellTalkDB. To use
your own lrpairs data.frame, please refer to demo_lrpairs()
to build a new one, e.g., rat, zebrafish, Drosophila, C. elegans,
etc.
# demo_lrpairs
demo_lrpairs()
#> ligand receptor species
#> 1 CX3CL1 CX3CR1 Human
#> 2 TGFB1 TGFBR2 Human
#> 3 CCL2 CCR2 Human
#> 4 Sst Sstr1 Mouse
# find highly expressed LR pairs
obj <- find_lrpairs(object = obj, lrpairs = lrpairs, min_cell_num = 10, cell_min_pct = 0.1, p_value = 0.05)
#> Finding highly expressed LR pairs
# results is stored in obj@cci
cci <- obj@cci
head(cci)
#> celltype_sender celltype_receiver ligand receptor ligand_pct ligand_exp_avg
#> 1 acinar_cell acinar_cell VIM CD44 0.6155718 0.8339240
#> 2 acinar_cell acinar_cell C3 CD46 0.5255474 0.8740566
#> 3 acinar_cell acinar_cell CXCL12 ITGB1 0.6496350 0.6158164
#> 4 acinar_cell acinar_cell LMAN1 MCFD2 0.8199513 0.7800645
#> 5 acinar_cell acinar_cell CXCL12 SDC4 0.6496350 0.6158164
#> 6 acinar_cell alpha_cell C3 CD46 0.5255474 0.8740566
#> ligand_z_score ligand_p_value receptor_pct receptor_exp_avg receptor_z_score
#> 1 2.611653 0.004505282 0.9075426 2.2410825 7.678032
#> 2 2.756148 0.002924328 0.8077859 0.8377001 2.625249
#> 3 1.826372 0.033897157 0.7883212 0.6926912 2.103154
#> 4 2.417736 0.007808710 0.8223844 0.9291400 2.954472
#> 5 1.826372 0.033897157 0.7737226 0.7283321 2.231477
#> 6 2.756148 0.002924328 0.9227683 1.6624160 5.250688
#> score
#> 1 1.8688924
#> 2 0.7321973
#> 3 0.4265706
#> 4 0.7247891
#> 5 0.4485189
#> 6 1.4530456[4] Visualize the cell-cell communications with
plot_cci_chord(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltypewhich cell types to plot by order. Default is to plot all cell typescelltype_colorColors for the cell types, whose length must be equal tocelltypeligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorsedge_colorColors for the edges from the sender cell type, whose length must be equal to celltypeedge_typeTypes for the edges from the sender cell type. Default is “big.arrow”. “ellipse” for ellipse, “triangle” for triangle, “curved” for curved. Details seecirclize::chordDiagramshow_typewhich type to show, and for sum of inferred LR number and score, respectively. Default isif_show_autocrineWhether to show autocrine. Default istext_sizeSize of text labels. Default isy_scaley_scale to adjust the text. Default is...parameters pass tocirclize::chordDiagram, e.g.,link.arr.width,link.arr.length,link.arr.col
plot_cci_chord(object = obj)[5] Visualize the cell-cell communications with
plot_cci_circle(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltypewhich cell types to plot. Default is to plot all cell typesligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorscelltype_colorColors for the cell types, whose length must be equal tocelltypeedge_colorColors for the edges from the sender cell type, whose length must be equal tocelltypeedge_typeTypes for the edges. “fan” by default, “link”, “hive”show_typewhich type to show, “number” and “score” for sum of inferred LR number and score, respectively. Default is “number”if_show_autocrineWhether to show autocrine. Default isFALSEedge_alphaTransparency of edge. Default is 0.5node_sizeSize of node. Default is 10text_sizeSize of text. Default is 5
plot_cci_circle(object = obj)Note
To show one or more senders or receivers by retaining all cell types,
users can use plot_cci_circle_simple() for plotting.
[6] Visualize the cell-cell communications with
plot_cci_circle_simple(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltypewhich cell types to plot. one or more cell typescelltype_dirwhich direction to plot, “sender” or “receiver”. Default is as “sender”ligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorscelltype_colorColors for the cell types, whose length must be equal tocelltypeedge_colorColors for the edges from the sender cell type, whose length must be equal tocelltypeedge_typeTypes for the edges. “fan” by default, “link”, “hive”show_typewhich type to show, “number” and “score” for sum of inferred LR number and score, respectively. Default is “number”if_show_autocrineWhether to show autocrine. Default isFALSEedge_alphaTransparency of edge. Default is 0.5node_sizeSize of node. Default is 10text_sizeSize of text. Default is 5
# as sender
plot_cci_circle_simple(object = obj, celltype = "ductal_cell", celltype_dir = "sender")
# as receiver
plot_cci_circle_simple(object = obj, celltype = "ductal_cell", celltype_dir = "reciver")[7] Visualize the cell-cell communications with
plot_cci_heatmap(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltypewhich cell types to plot. Default is to plot all cell typesligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorscelltype_colorColors for the cell types, whose length must be equal tocelltypeedge_colorColors for the edges from the sender cell type, whose length must be equal tocelltype, or use “NO” to cancel itshow_typewhich type to show, “number” and “score” for sum of inferred LR number and score, respectively. Default is “number”if_show_autocrineWhether to show autocrine. Default isFALSEedge_alphaTransparency of edge. Default is 0.5node_sizeSize of node. Default is 40text_sizeSize of text. Default is 15node_padSize of node padding. Numeric essentially influences the width height. Default is 20...parameters pass tonetworkD3::sankeyNetwork
plot_cci_heatmap(object = obj)[8] Visualize the cell-cell communications with
plot_cci_sankey(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltypewhich cell types to plot by order. Default is to plot all cell typesligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorsshow_typewhich type to show, “number” and “score” for sum of inferred LR number and score, respectively. Default is “number”text_sizeSize of text labels. Default is 10viridis_optionoption inviridis::scale_color_viridis, can be “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”. Default is “D”....parameters pass toheatmaply::heatmaply, e.g., grid_color
plot_cci_sankey(object = obj)[9] Visualize the LR interactions with
plot_cci_lrpairs_heatmap(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltypewhich cell types to plot. Default is to plot all cell typesligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorsif_show_autocrineWhether to show autocrine. Default isFALSEif_horizontalWhether to plot with the horizontal direction. Default isTRUEtext_sizeSize of text labels. Default is 10viridis_optionoption inviridis::scale_color_viridis, can be “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”. Default is “D”....parameters pass toheatmaply::heatmaply, e.g., grid_color
plot_cci_lrpairs_heatmap(object = obj)[10] Visualize the LR interactions with
plot_cci_lrpairs_bubble(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltypewhich cell types to plot. Default is to plot all cell typesligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorsif_show_autocrineWhether to show autocrine. Default isFALSEif_horizontalWhether to plot with the horizontal direction. Default isTRUEsizeSize of the bubble. Default is 2viridis_optionoption inviridis::scale_color_viridis, can be “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”. Default is “D”.
plot_cci_lrpairs_bubble(object = obj)Note
To filter the top LR interactions, users can use
get_top_lrpairs() for plotting
obj_filter <- obj
obj_filter@cci <- get_top_lrpairs(object = obj_filter, top_n = 5)
plot_cci_lrpairs_bubble(object = obj_filter, size = 2, if_horizontal = FALSE)plot_cci_lrpairs_heatmap(object = obj_filter, celltype = c("alpha_cell","beta_cell", "delta_cell", "ductal_cell"))[11] Visualize the LR interactions with
plot_lrpairs_chord(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltype_senderName of celltype_sender. One or more cell typescelltype_receiverName of celltype_receiver. One or more cell typescelltype_colorColors for the celltype_sender nodes and celltype_receiver nodes, or use “NO” to make it simpleligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorsedge_colorColors for the edges from the sender cell typeedge_typeTypes for the edges from the sender cell type. Default is “circle”, “big.arrow” for big arrow, “triangle” for triangle, “ellipse” for ellipse, “curved” for curved. Details seecirclize::chordDiagramtext_sizeSize of text labels. Default is 0.5y_scaley_scale to adjust the text. Default is 1...parameters pass tocirclize::chordDiagram, e.g.,link.arr.width,link.arr.length,link.arr.col
plot_lrpairs_chord(obj,celltype_sender = "alpha_cell",celltype_receiver = "beta_cell",link.arr.width = 0.5, link.arr.length = 0.2, text_size = 0.8)[12] Visualize the LR interactions with
plot_lrpairs_heatmap(), parameters see below:
objectscCrossTalk object afterfind_lrpairscelltype_senderName of celltype_sender. One or more cell typescelltype_receiverName of celltype_receiver. One or more cell typesligandwhich ligand to use. Default is to plot all inferred ligandsreceptorwhich receptor to use. Default is to plot all inferred receptorstext_sizeSize of text labels. Default is 3if_horizontalWhether to plot with the horizontal direction. Default isTRUEviridis_optionoption inviridis::scale_color_viridis, can be “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”. Default is “D”....parameters pass toheatmaply::heatmaply, e.g., grid_color
plot_lrpairs_heatmap(obj,celltype_sender = "alpha_cell",celltype_receiver = "beta_cell")About
Please refer to the scCrossTalk on GitHub or the document or tutorial-jupyter for more information.